<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>ws</title>
</head>
<body>
    <div id="responsed">ddd</div>
    <input type="text"  id="message">
    <button id="submitBtn">发送</button>
    <script type="module">
        const ws = new WebSocket('ws://localhost:8888/v1/ws')
        const input = document.querySelector('#message')
        const submitBtn = document.querySelector('#submitBtn')
        const responsed = document.querySelector('#responsed')
        submitBtn.addEventListener('click', ()=>{
            ws.send(input.value)
        })
        ws.onopen = ()=>{
            console.log("连接成功")
        }
        ws.onmessage = (e)=>{
            responsed.textContent = e.data
           
        }

        
    </script>
</body>
</html>